#
# PodPlaylistDrag.py
#
# This work is released under the GNU GPL, version 2 or later.
#
from qt import QStoredDrag

_podplaylistmimetype = 'application/x-podplaylist'

#
# this class encapsulates a drag of a playlist from a source list - all that's transferred
# is the name of the playlist
#
class PodPlaylistDrag(QStoredDrag):
	def __init__(self,playlist,widget):
		QStoredDrag.__init__(self,_podplaylistmimetype,widget)
		packet = {'Playlist':playlist.name}
		#print "PodPlaylistDrag",packet
		self.setEncodedData(str(packet))
		#print "encoded drag"

	def playlistName(self):
		packet = eval(self,encodedData(_podplaylistmimetype))
		return packet['Playlist']
	
	def class_canDecode(cls,event):
		return event.provides(_podplaylistmimetype)

	canDecode = classmethod(class_canDecode)

	def class_decode(cls,event):
		return eval(str(event.encodedData(_podplaylistmimetype)))

	decode = classmethod(class_decode)
